﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace Gollie.Controls
{
	public partial class PageContentInjector : System.Web.UI.UserControl
	{
		protected override void Render(HtmlTextWriter writer)
		{
			string p = Path.GetFileNameWithoutExtension(Request.CurrentExecutionFilePath).ToLower();
			var pc = PageConfigurator.GetInstance()[p];

			if (pc != null)
			{
				if (Type == "header")
				{
					writer.Write(pc.TitleHtml);
					writer.Write(pc.MetaHtml);
					writer.Write(pc.PreloadHtml);
					writer.Write(pc.CSSHtml);
				}
				else if (Type == "script")
				{
					writer.Write(pc.JSHtml);
				}
			}
		}

		public string Type { get; set; }
	}
}